<div id="information">
<br /><br />
<?php
$id = (int)$_GET['id'];
/* защита по ид */
if(!isset($id) || !is_numeric($id) || $id<1){
	echo "<h2>Не мога да намеря страницата</h2>";
}else {
	$username = $_SESSION['username'];
	$sel_username = mysql_query('SELECT * FROM users WHERE username = "'.$username.'"');
	$row_u = mysql_fetch_assoc($sel_username);
	
	if($row_u['type'] == 3 || $row_u['type'] == 2 || $row_u['type'] == 1) {
?>
	<div id='admin_add_t'>
		<p>
			<a href='add_t.php?id=<?php echo $_GET['id'];?>'>Добави нова тема към категорията</a>
		</p>
	</div>
<?php	
}
$sel = "SELECT * FROM categories WHERE id=".$_GET['id']."";
$sel_q = mysql_query($sel);

	    $row_i=mysql_fetch_assoc($sel_q);
		$selll = "SELECT * FROM cat_t WHERE c_title='".$sel_q."'";
		$sell_qq = mysql_query($selll);
		
		$sell = "SELECT * FROM com_t WHERE title_t='".$sell_qq."'";
		$sell_q = mysql_query($sell);
?>
	<div id='forum_DIV_see'>	
		<table id='table_DIV_see'>
			<tr>
				<td style='padding-left: 20px; color: #fff;'>Тема</td>
				<td width='200px' align='right' style='padding-right: 20px; color: #fff;'>Създадена от</td>
			</tr>
		</table>
		
		<?php
		   if($_GET['moda']=="delete"){
		    $delete_f='DELETE FROM cat_t WHERE id="'.$_GET['tema'].'"';
			$results_delete_f=mysql_query($delete_f);
			
			$delete_mn='DELETE FROM com_t WHERE `title_t`='.$_GET['tema'].'';
			$res_del_mn=mysql_query($delete_mn);
			
			echo '
			<script type="text/javascript">
			alert("Успешно Изтриване!");
			</script>
			';
			echo '<meta http-equiv="refresh" content="0;url=see_cat.php?id='.$_GET['id'].'">';
		   } else {
			$sel_allt = mysql_query("SELECT * FROM cat_t WHERE c_title='".$row_i['cat_title']."'");
			
			if(mysql_num_rows($sel_allt)==0){
			   echo '<p class="error">Няма теми към тази категория!</p>';
			} 
			while($row_a = mysql_fetch_assoc($sel_allt)){
		?>
		<br />
		<table id='table_DIV_see2'>
			<tr>
				<td style='padding-left: 10px;background:none;'><a href='see_t.php?id=<?php echo $row_a['id'];?>'><b><?php echo ucfirst($row_a['t_title']);?></b></a></td>
				<?php
					$selec = mysql_query("SELECT * FROM users WHERE username='".$row_a['who_added']."'");
					$row_sec = mysql_fetch_assoc($selec);
					$id_user = $row_sec['id'];
				?>
				<td width='150px' align='right' style='text-align: center;background:none;'>
					<a href='../user_profile/profile_another.php?id=<?php echo $id_user;?>'><?php echo $row_a['who_added'];?></a>
									<?php
				if($_SESSION['username']=="admin"){
				  echo '<a href="see_cat.php?id='.$_GET['id'].'&amp;tema='.$row_a['id'].'&amp;moda=delete" class="show">
				  <img src="../img/delete.png" width="15px" height="15px" alt="delete" style="position: relative; left: 15px; bottom: 0px;"/></a>';
				}
				?>
				</td>
			</tr>
		</table>
			<hr width='92%' style='border-top: 1px  dashed black;'/>
		<?php
		}
		?>
		<br />
	</div>	
<?php
}
}
?>
<br />
</div>